class PlataformaController < ApplicationController
  
  
   def login
    
    if request.post?
     
  @usuario = Usuario.find_by_login_and_senha(params[:login], params[:senha])
    if @usuario
      session[:usuario] = @usuario.id
     # if session[:return_to] && !session[:return_to].include?(url_for(:action => "login"))
     #   redirect_to session[:return_to]
     ##   session[:return_to] = nil
     # else
        redirect_to :controller => "usuarios", :action=>"index"
    
    else
      flash[:notice] = "Invalid Login and/ord password " 
      redirect_to :controller => "plataforma", :action=>"index"
      end
    end
  end

  def logout
    session[:usuario] = nil
    redirect_to :controller => "plataforma"
  end
  
end